package org.example.aienglishapp.controller.progress;


import org.example.aienglishapp.entity.progress.LearningStat;
import org.example.aienglishapp.service.progress.LearningStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/LEARNING_STATS") // 允许来自前端 React 应用的跨域请求
public class LearningStatController {

    private final LearningStatService learningStatService;

    @Autowired
    public LearningStatController(LearningStatService learningStatService) {
        this.learningStatService = learningStatService;
    }

    @GetMapping("/{userId}")
    public List<LearningStat> getLearningStats(@PathVariable Long userId) {
        System.out.println("Received userId: " + userId); // 打印接收到的 userId
        return learningStatService.getLearningStats(userId);
    }
}